package com.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.bean.TestBean;
import com.demo.dao.TestDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * @author mifei
 * @create 2020-07-30 16:25
 **/
@Service
public class UserServiceImpl extends ServiceImpl<TestDao, TestBean> {

    @Autowired
    private TestDao testDao;

    public Object queryPage(Map<String, Object> params) {
        String username = (String)params.get("name");
        IPage<TestBean> page = new Page<>(1, 5);
        page.setSize(5);
        page.setCurrent(0);
        IPage<TestBean> pages = testDao.selectPage(page,
                new QueryWrapper<TestBean>()
                        .like(!StringUtils.isEmpty(username),"name", username)
        );
        return pages;
    }
}
